export function formaterTableData(data) { // 格式化表格数据
  if (data.length > 0) {
    data.map((item, index) => {
      for (var i in item) {
        if (item[i] === null || '') {
          item[i] = ' '
        }
      }
    })
	return data
  }
}

export function initScrollTop(name) { // 滚动条位置0
  setTimeout(function() {
    document.getElementById(name).scrollTop = 0
  }, 200)
}
export function scrollBottom(name) { // 滚动条滚动到底部位置
  setTimeout(function() {
    let div = document.getElementById(name)
    div.scrollTop = div.scrollHeight
  }, 200)
}

export function clearForm(obj) { // 清空表单
  if (typeof obj === 'object') {
    for(const [key, value] of Object.entries(obj)) {
	  if(value instanceof Array) {
		obj[key] = []
	  } else if (typeof value === 'boolean') {
		obj[key] = false
	  } else if (typeof value === 'number') {
		obj[key] = null
	  } else if (typeof value === 'object' && value !== null) {
		 for(const [i, item] of Object.entries(value)) {
      value[i] = ''
     }
	  } else {
      obj[key] = ''
    }
	}
  }
}
